import { HelpListValueProps } from './HelpChildren.vue';

export const helpList: HelpListValueProps[] = reactive([
  {
    name: '弹框提示',
    value:
      "configPageParams.useHandleData(()=>configPageParams.http['get'](`/page/delete/${row.id}`),null,`删除${row.pname}`,configPageParams.tableRefs.tableRef.getTableList);",
    remark: 'api, params, name, refresh',
    isOpen: false
  },
  {
    name: '打开引入组件',
    value: `
    configPageParams.tableRefs.tableRef.clickRow = row;
    configPageParams.components.updateRoleRef.open();`,
    remark: ''
  },
  {
    name: '表单',
    value: '',
    isOpen: false,
    children: [
      {
        name: '页面中表单Ref',
        value: 'configPageParams.formRefs',
        isOpen: true
      },
      {
        name: '表单方法',
        value: '',
        isOpen: true,
        children: [
          {
            name: '获取页面中表单',
            value: 'configPageParams.formObj.addForm'
          },
          {
            name: '表单下拉框请求',
            value: `
            const data = await configPageParams.http['post']("permission/listTree",{type:["menu"]});
            return configPageParams.arrOperation.treeToSelect(data,"description","permName");
            `
          },
          {
            name: '表单树结构下拉请求',
            value: `
            const data = await configPageParams.http['post']("permission/listTree",{type:["menu"]});
            return configPageParams.arrOperation.arrTransitionSelectData(data,"description","permName");
            `
          },
          {
            name: '表单保存',
            value: ``,
            isOpen: true,
            children: [
              {
                name: '主表单保存',
                value: `
                const url = form.id ? "/dic/update":"/dic/save"
                await configPageParams.http.post(url,form) ;
                configPageParams.tableRefs.tableRef.getTableList();
                `
              },
              {
                name: '明细表单保存',
                value: `
                      console.log(configPageParams.tableRefs.tableRef.clickRow);
                        const {id}  = configPageParams.tableRefs.tableRef.clickRow ||{};
                        if(!id){
                        configPageParams.el.elMessage("请选择主表格数据","warning");
                        return;
                        }
                        console.log(id);
                        const params= {
                        pageId:id
                        }
                        configPageParams.dynamicModes.formUtils.formConfigFormOpen(configPageParams.formObj.configAddForm,"新增明细",params)
                      `
              }
            ]
          }
        ]
      },
      {
        name: '表单工具',
        value: 'formUtils',
        isOpen: true,
        children: [
          {
            name: '状态修改',
            value: 'configPageParams.dynamicModes.formUtils.formChangeItemStatus',
            remark: `form: basicForm,fields: Array<string>,flag = false,type: "disabled" | "hide" = "disabled"`
          },

          {
            name: '打开表单',
            value: `configPageParams.dynamicModes.formUtils.formConfigFormOpen(configPageParams.formObj.addForm,"打开",row)`,
            remark: 'formData, title: string, row?: Object'
          },
          {
            name: '获取表单项中选择项',
            value: 'configPageParams.dynamicModes.formUtils.formGetChildren',
            remark: 'form: any, props: any'
          },
          {
            name: '远程搜索方法',
            value: 'configPageParams.dynamicModes.formUtils.formRemoteMethod',
            remark: `form: basicForm,code: string,api: Function,params: string | T,initDisplayField = ["value", "id"]`
          },
          {
            name: '设置表单选择项',
            value: 'configPageParams.dynamicModes.formUtils.formSetChildren',
            remark: 'form, children: Map<string, childrenProps[]>'
          },
          {
            name: '设置表单项验证规则',
            value: 'configPageParams.dynamicModes.formUtils.fromChangeVerifyRole',
            remark: 'form: any, props: any, required: boolean'
          }
        ]
      }
    ]
  },

  {
    name: '表格',
    value: '',
    isOpen: false,
    children: [
      {
        name: '表格查询参数',
        value: '',
        isOpen: true,
        children: [
          {
            name: '接口验证字段',
            value: 'id,请先选择页面 || id',
            remark: 'tableParams: any'
          },
          {
            name: '接口参数',
            value: `
             {
                "pageId": "$configPageParams.tableRefs.tableRef.clickRow.id",
                "v1": "url=>configPageParams.tableRefs.tableRef.clickRow.id",
                "v2": "33"
              }
            `,
            remark: `
              "id":"url=>configPageParams.tableRefs.pageTableRef.clickRow.id" (路径传参)
              "pageId":"$id" (传递参数)
              "id":"123" (静态传参)
            `
          }
        ]
      },
      {
        name: '表格枚举配置',
        value: `
          [{
            "label": "表单",
            "value": "form",
            "type": "option",
            "tagType": "success"
          }, {
            "label": "表格",
            "value": "table",
            "type": "option",
            "tagType": "warning"
          }]
        `,
        remark: 'success  |  warning | info | danger'
      },
      {
        name: '接口回调',
        value: `data.records.forEach(item=>{
          item.userStr = configPageParams.arrOperation.arrJoinToStr(item.userList,"nick");
         });
         return data;
         `,
        remark: 'success  |  warning | info | danger'
      },
      {
        name: '表格Ref',
        value: 'configPageParams.tableRefs',
        isOpen: true,
        children: [
          {
            name: '操作项',
            value: "{ prop: 'operation', label: 'operation', fixed: 'left', width: 200 }"
          },
          {
            name: '清除选中',
            value: 'clearSelection'
          },
          {
            name: '选中行',
            value: 'clickRow'
          },
          {
            name: '刷新',
            value: 'getTableList'
          },
          {
            name: '更新查询参数并刷新',
            value: 'search'
          },
          {
            name: '初始化查询参数',
            value: 'searchInitParam'
          },
          {
            name: '查询参数',
            value: 'searchParam'
          },
          {
            name: '选中行数据集合',
            value: 'selectedList'
          },
          {
            name: '选中行id集合',
            value: 'selectedListIds'
          }
        ]
      }
    ]
  },
  {
    name: '弹框表格',
    value: ``,
    isOpen: false,
    children: [
      {
        name: '打开弹框表格',
        value: ' configPageParams.tableRefs.dialogRef.open();'
      }
    ]
  },

  {
    name: '全局按钮',
    value: ``,
    isOpen: false,
    children: [
      {
        name: '表格内按钮隐藏条件',
        value: `
        if(row === undefined || JSON.stringify(row) === "{}") return;
        return row.status === 1;
        `
      },
      {
        name: '全局按钮隐藏条件',
        value: `
        return row.status === 1;
        `
      }
    ]
  },
  {
    name: 'elementPlus方法',
    value: 'configPageParams.el',
    isOpen: false,
    children: [
      {
        name: '提示弹框',
        value: 'configPageParams.el.elMessage',
        remark: `message: string, type:  'success' | 'warning' | 'info' | 'error';`
      }
    ]
  },
  {
    name: '其他引入的方法',
    value: '',
    isOpen: false,
    children: [
      {
        name: '复制文本',
        value: `configPageParams.outer.fallbackCopy(text)`,
        remark: `text: string;`
      },
      {
        name: '导出|下载',
        value: `configPageParams.outer.exportData()`,
        remark: `data: BlobPart, title: string, flag(是否直接添加xlsx后缀): boolean = false`
      },
      {
        name: '环境配置',
        value: '',
        isOpen: true,
        children: [
          {
            name: '获取文件访问地址',
            value: 'configPageParams.outer.environment.getFileUrl()'
          }
        ]
      }
    ]
  },
  {
    name: 'axios请求',
    value: "configPageParams.http['get'](/page/delete/${row.id})"
  },
  {
    name: '路由跳转',
    value: 'configPageParams.routerPush',
    remark: 'path: string, params?: any'
  },
  {
    name: '自定义下拉选择示例',
    value: `[{"label":"是","value":"1","type":"option"},{"label":"否","value":"0","type":"option"}]`
  },
  {
    name: 'window上方法',
    value: 'configPageParams.windowFunction',
    isOpen: false,
    children: [
      {
        name: '打开新窗口或聚焦到已存在的窗口',
        value: 'configPageParams.windowFunction.openOrCreateWindow',
        remark: 'url:string,name?:string'
      }
    ]
  },
  {
    name: '基础的数组操作方法',
    value: 'configPageParams.arrOperation',
    isOpen: false,
    children: [
      {
        name: '根据数组中指定字段进行合并  并对指定字段数量进行求和',
        value: 'configPageParams.arrOperation.arrMergeRow',
        remark: 'data: any[], mergeField: string, sumField: string'
      },
      {
        name: '对数组中的所有数字进行取整千分号',
        value: 'configPageParams.arrOperation.arrRoundOff',
        remark: 'data: any[], mergeField: string, sumField: string'
      },
      {
        name: '对数组中的所有数字添加千分号',
        value: 'configPageParams.arrOperation.arrRoundingFunction',
        remark: 'arr: any[]'
      },
      {
        name: '根据指定字段进行排序',
        value: 'configPageParams.arrOperation.arrSortItemsByName',
        remark: 'arr: Array<any>, field: string, sortFlag: boolean = false'
      },
      {
        name: '数组字段求和',
        value: 'configPageParams.arrOperation.arrSummation',
        remark: 'data: Array<any>, field: string'
      },
      {
        name: '转换为下拉框需要数据',
        value: 'configPageParams.arrOperation.arrTransitionSelectData',
        remark: "originArr: Array<any>, label: string, value: string = ''"
      },
      {
        name: '树形数据转换为下拉框需要数据',
        value: 'configPageParams.arrOperation.treeToSelect',
        remark: 'originArr: Array<any>, label: string, value: string'
      },
      {
        name: '将复杂数组中某个字段提取出来',
        value: 'configPageParams.arrOperation.arrLiftField',
        remark: 'arr: Array<any>, field: string'
      },
      {
        name: '将复杂数组中某个字段转字符串拼接',
        value: 'configPageParams.arrOperation.arrJoinToStr',
        remark: 'data: any[], mergeField: string, sumField: string'
      },
      {
        name: '将数组格式内容转字符串拼接',
        value: 'configPageParams.arrOperation.arrSimpleJoinToStr',
        remark: "arr: Array<number | string>, flag =','"
      }
    ]
  },
  {
    name: '时间格式处理',
    value: 'configPageParams.dayjs'
  },
  {
    name: '数值计算',
    value: 'configPageParams.calculate',
    isOpen: false,
    children: [
      {
        name: '加法',
        value: 'configPageParams.calculate.add'
      },
      {
        name: '减法',
        value: 'configPageParams.calculate.subtract'
      },
      {
        name: '乘法',
        value: 'configPageParams.calculate.multiply'
      },
      {
        name: '除法',
        value: 'configPageParams.calculate.divide'
      },
      {
        name: '计算A是B的百分之多少',
        value: 'configPageParams.calculate.calculatePercentage',
        remark: 'a: number, b: number'
      },
      {
        name: '保留 digit 位小数',
        value: 'configPageParams.calculate.toFixed',
        remark: 'number: number, digit: number = 2'
      }
    ]
  }
]);
